﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using UIWindows.Tools.Helper;

namespace UIWindows.Tools.Converter
{
    [ValueConversion(typeof(long), typeof(DateTime))]
    public class TimeStampToDateTimeStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                long age = (long)value;
                return age == 0 ? default : age.GetDateTime();
            }
            catch (Exception)
            {
                return default;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
